import multiprocessing
import time


# 保存数据
def set_num1(temp_queue):
    list1 = [1, 2, 3, 4, 5, 6]
    for temp in list1:
        temp_queue.put(temp)
    print(f"保存数据成功:{list1}")


# 获取数据
def set_num2(temp_queue):
    while True:
        if temp_queue.empty():
            break
        print(f"打印数据：{temp_queue.get()}")
        time.sleep(1)


if __name__ == "__main__":
    temp_queue = multiprocessing.Queue()
    # 创建进程
    p1 = multiprocessing.Process(target=set_num1, args=(temp_queue,))
    p2 = multiprocessing.Process(target=set_num2, args=(temp_queue,))
    p1.start()
    p2.start()
